package com.ruoyi.web.controller.system;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.ruoyi.web.controller.tool.JsonResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ZhuanjiaQushiquerenPici;
import com.ruoyi.system.service.IZhuanjiaQushiquerenPiciService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家核查批次Controller
 * 
 * @author ruoyi
 * @date 2023-06-12
 */
@Controller
@RequestMapping("/system/qushiquerenpici")
public class ZhuanjiaQushiquerenPiciController extends BaseController
{
    private String prefix = "system/qushiquerenpici";

    @Autowired
    private IZhuanjiaQushiquerenPiciService zhuanjiaQushiquerenPiciService;

    @RequiresPermissions("system:qushiquerenpici:view")
    @GetMapping()
    public String qushiquerenpici()
    {
        return prefix + "/qushiquerenpici";
    }

    @GetMapping("/customlist")
    public String customlist()
    {
        return prefix + "/customqushiquerenpici";
    }

    /**
     * 查询专家核查批次列表
     */
    //@RequiresPermissions("system:qushiquerenpici:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZhuanjiaQushiquerenPici zhuanjiaQushiquerenPici)
    {
        startPage();
        List<ZhuanjiaQushiquerenPici> list = zhuanjiaQushiquerenPiciService.selectZhuanjiaQushiquerenPiciList(zhuanjiaQushiquerenPici);
        return getDataTable(list);
    }

    /**
     * 导出专家核查批次列表
     */
    //@RequiresPermissions("system:qushiquerenpici:export")
    @Log(title = "专家核查批次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZhuanjiaQushiquerenPici zhuanjiaQushiquerenPici)
    {
        List<ZhuanjiaQushiquerenPici> list = zhuanjiaQushiquerenPiciService.selectZhuanjiaQushiquerenPiciList(zhuanjiaQushiquerenPici);
        ExcelUtil<ZhuanjiaQushiquerenPici> util = new ExcelUtil<ZhuanjiaQushiquerenPici>(ZhuanjiaQushiquerenPici.class);
        return util.exportExcel(list, "专家核查批次数据");
    }

    /**
     * 新增专家核查批次
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存专家核查批次
     */
    //@RequiresPermissions("system:qushiquerenpici:add")
    @Log(title = "专家核查批次", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZhuanjiaQushiquerenPici zhuanjiaQushiquerenPici)
    {
        zhuanjiaQushiquerenPici.setId(UUID.randomUUID().toString());
        zhuanjiaQushiquerenPici.setKaishishijian(new Date());
        zhuanjiaQushiquerenPici.setRenshu((long)0);
        zhuanjiaQushiquerenPici.setWeihecha((long)0);
        zhuanjiaQushiquerenPici.setYihecha((long)0);
        zhuanjiaQushiquerenPici.setIsvalid((long)1);
        return toAjax(zhuanjiaQushiquerenPiciService.insertZhuanjiaQushiquerenPici(zhuanjiaQushiquerenPici));
    }

    /**
     * 修改专家核查批次
     */
    @RequiresPermissions("system:qushiquerenpici:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZhuanjiaQushiquerenPici zhuanjiaQushiquerenPici = zhuanjiaQushiquerenPiciService.selectZhuanjiaQushiquerenPiciById(id);
        mmap.put("zhuanjiaQushiquerenPici", zhuanjiaQushiquerenPici);
        return prefix + "/edit";
    }

    /**
     * 修改保存专家核查批次
     */
    //@RequiresPermissions("system:qushiquerenpici:edit")
    @Log(title = "专家核查批次", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZhuanjiaQushiquerenPici zhuanjiaQushiquerenPici)
    {
        return toAjax(zhuanjiaQushiquerenPiciService.updateZhuanjiaQushiquerenPici(zhuanjiaQushiquerenPici));
    }

    /**
     * 删除专家核查批次
     */
    //@RequiresPermissions("system:qushiquerenpici:remove")
    @Log(title = "专家核查批次", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zhuanjiaQushiquerenPiciService.deleteZhuanjiaQushiquerenPiciByIds(ids));
    }

    @PostMapping("/findone")
    @ResponseBody
    public JsonResult<?> findone(@RequestParam("id")String ppId)
    {
        ZhuanjiaQushiquerenPici mmPici = zhuanjiaQushiquerenPiciService.selectZhuanjiaQushiquerenPiciById(ppId);
        if (mmPici==null){
            return  JsonResult.getErrorResult("该批次查询失败");
        }

        return JsonResult.getSuccessResult(mmPici);
    }

    @PostMapping( "/delete")
    @ResponseBody
    public AjaxResult delete(@RequestParam("id") String ppId)
    {
        return toAjax(zhuanjiaQushiquerenPiciService.deleteZhuanjiaQushiquerenPiciById(ppId));
    }
}
